home *** CD-ROM | disk | FTP | other *** search
- WiseStampLog("[gmail.js] >>>>>");
- window.addEventListener("load",function(event){gmailsig.pageload(event)},true);
- window.addEventListener("unload",function(event){gmailsig.unload(event)},true);
-
- var gmailsig =
- {
- gmail: null,
- current: null,
- pageload: function (event)
- {
- WiseStampLog("[gmail.js::pageload] >>>>>");
- wisestampsig.refreshCallback = gmailsig.refreshSignature;
- gmailsig.setupCompose();
- window.addEventListener("DOMNodeInserted", gmailsig.nodeInserted, false);
- },
- unload: function(event)
- {
- },
- handleEvent: function (event)
- {
- WiseStampLog("[gmail.js::handleEvent] >>>>>");
- WiseStampLog("[gmail.js::handleEvent] Event: " + event + "|" + event.type);
- },
- createOptionsIcon: function ()
- {
- var wisestampIcon = document.createElement("span");
- //wisestampIcon.innerHTML="Wisestamp Options";
- wisestampIcon.setAttribute("class", "wisestampIcon");
- wisestampIcon.innerHTML = '<img src="' + wisestampsig.icon + '" width="16" height="16"/>';
- //wisestampIcon.style.marginLeft="10px";
- //wisestampIcon.style.verticalAlign="middle";
- wisestampIcon.setAttribute("style", "margin-left: 10px; margin-bottom: 10px;");
- return wisestampIcon;
- },
- setupCompose: function ()
- {
- WiseStampLog("[gmail.js::setupCompose] >>>>>");
-
- setTimeout(function (a)
- {
- gmailsig.addWisestampIcon();
- },
- 500, this);
-
- this.insertSignature();
- },
- iframeTries: 1,
- refreshSignature: function ()
- {
- gmailsig.insertSignature(null, true, "//div[@class='gmail_quote']");
- },
- insertSignature: function (iframe, manual, xPath)
- {
- WiseStampLog("[gmail.js::insertSignature] >>>>>");
- WiseStampLog("[gmail.js::insertSignature] try: " + this.iframeTries);
-
- var retry = !iframe;
- if (!iframe)
- {
- var iframes = document.getElementsByTagName("iframe");
- for (var i = 0; i < iframes.length; i++)
- {
- if (iframes[i].contentDocument && iframes[i].contentDocument.designMode == "on")
- {
- iframe = iframes[i];
- wisestampsig.insertSignature(iframe, !manual, xPath);
- retry = false;
- }
- }
- }
- if (retry && this.iframeTries < 1)
- {
- this.iframeTries++;
- setTimeout(function (a)
- {
- a.insertSignature(null, manual, xPath);
- },
- 0, this);
- }
- },
- nodeInserted: function (event)
- {
- if (event.target && "tagName" in event.target && event.target.tagName == "IFRAME")
- {
- var iframe = event.target;
-
- WiseStampLog("iframe inserted: " + event.target + "\n");
- gmailsig._iframe = iframe;
-
- /* Now listen for when the form closes */
- gmailsig.addWisestampIcon();
- iframe.addEventListener('load', gmailsig.iframeLoad, false);
- }
- },
- iframeLoad: function (event)
- {
- WiseStampLog("[gmail.js::iframeLoad(" + event + "|" + event.target + ")] >>>>>");
-
- setTimeout(function ()
- {
- WiseStampLog("[gmail.js::setTimeout] >>>>>");
- var iframe = gmailsig._iframe;
- if (iframe.contentDocument && iframe.contentDocument.designMode == "on")
- wisestampsig.insertSignature(iframe, true);
-
- if (event)
- {
- try
- {
- event.target.removeEventListener('load', gmailsig.iframeLoad, false);
- } catch(e)
- {}
- }
- },
- !event ? 500 : 0);
- },
- addWisestampIcon: function ()
- {
- WiseStampLog("[gmail.js::addWisestampIcon] >>>>>");
- if (!wisestampsig.showButton) return;
- //var containers = evaluateXPath(gmailsig.view.ownerDocument,"//td[@class='VByZEe']");
- var containers = evaluateXPath(document, "//span[@class='jNNpPe']");
- WiseStampLog("[gmail.js::addWisestampIcon] Containers length = " + containers.length);
- for (var i = 0; containers && i < containers.length; i++)
- {
- var cont = containers[i];
- var icons = evaluateXPath(cont, "//span[@class='wisestampIcon']");
- if (! (icons && icons.length > 0))
- {
- WiseStampLog("[gmail.js::addWisestampIcon] adding icon...");
- var wisestampIcon = gmailsig.createOptionsIcon();
- cont.appendChild(wisestampIcon);
- wisestampsig.initOptionsIcon(wisestampIcon);
- }
- }
- }
- };